<clr-datagrid (clrDgRefresh)="refresh($event)">
  <clr-dg-column >
    <ng-container  *clrDgHideableColumn="showState['ID']">
      ID
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'name'" style="min-width: 206px;">
    <ng-container *clrDgHideableColumn="showState['名称']">
      名称
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['URL']">
      URL
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['启用状态']">
      启用状态
    </ng-container>
  </clr-dg-column>
  <clr-dg-column [clrDgField]="'user'">
    <ng-container *clrDgHideableColumn="showState['创建用户']">
      创建用户 
    </ng-container>
  </clr-dg-column>
  <clr-dg-column>
    <ng-container *clrDgHideableColumn="showState['创建时间']">
      创建时间
    </ng-container>
  </clr-dg-column>
  <clr-dg-column
      *ngIf="
      authService.currentNamespacePermission.webHook.update ||
      authService.currentAppPermission.webHook.update ||
      authService.currentNamespacePermission.webHook.delete ||
      authService.currentAppPermission.webHook.delete ||
      authService.currentUser.admin"
  >
    <ng-container *clrDgHideableColumn="showState['操作']">
      操作
    </ng-container>
  </clr-dg-column>
  <clr-dg-row *ngFor="let w of webHooks; let i = index" [clrDgItem]="webHook">
    <clr-dg-cell>{{w.id}}</clr-dg-cell>
    <clr-dg-cell class="copy">{{w.name}}</clr-dg-cell>
    <clr-dg-cell>{{w.url}}</clr-dg-cell>
    <clr-dg-cell>
			<div class="toggle-switch">
				<input 
          type="checkbox"  
          id="webhook-toggle-{{i}}"
          (change)="toggleWebhook(w)"
          [checked]="w.enabled"
        >
        <label for="webhook-toggle-{{i}}"></label>
			</div> 
		</clr-dg-cell>
    <clr-dg-cell>{{w.user}}</clr-dg-cell>
    <clr-dg-cell>{{w.createTime | date:"yyyy-MM-dd HH:mm"}}</clr-dg-cell>
    <clr-dg-cell
      *ngIf="
      authService.currentNamespacePermission.webHook.update ||
      authService.currentAppPermission.webHook.update ||
      authService.currentNamespacePermission.webHook.delete ||
      authService.currentAppPermission.webHook.delete ||
      authService.currentUser.admin"
    >
      <button class="wayne-button text"
        *ngIf="
        authService.currentNamespacePermission.webHook.update ||
        authService.currentAppPermission.webHook.update ||
        authService.currentUser.admin"
        (click)="editWebhook(w)">
        编辑</button>
      <button class="wayne-button text"
        *ngIf="
        authService.currentNamespacePermission.webHook.delete ||
        authService.currentAppPermission.webHook.delete ||
        authService.currentUser.admin"
        (click)="deleteWebhook(w)">
        删除</button>
    </clr-dg-cell>
  </clr-dg-row>

  <wayne-paginate
    [(currentPage)]="currentPage"
    [total]="page.totalCount"
    [pageSizes]="[10, 20, 50]"
    (sizeChange)="pageSizeChange($event)"
  >
  </wayne-paginate>
</clr-datagrid>
